<table id="moduls_deterPerson_deterStat_dialog_datagrid"></table>

<div id="moduls_deterPerson_deterStat_datagrid_toolbar">
	<a href="javascript:void(0)" class="easyui-menubutton" data-options="menu:'#groupListMenu',iconCls:'icon-detailed'">按部门查看</a>
	
	<div id="groupListMenu" style="width:190px; height: 200px; overflow: auto;">  
	</div>
</div>

<div id="deterPerson_sugDiv"><span id="deterPerson_sugInfo"></span></div>

<script type="text/javascript">
$(function() {
	$('#moduls_deterPerson_deterStat_dialog_datagrid').datagrid({
		url : 'deterPersonAction!queryDeterStat.action',
		showGroup : true,
		scrollbarSize : 0,
		fit : true,
		fitColumns : false,
		pagination : true,
		border : false,
		toolbar : '#moduls_deterPerson_deterStat_datagrid_toolbar',
		columns : [ [ {
			title : '个人测评ID',
			field : 'contResId',
			width : 50,
			hidden : true
		}, {
			title : '员 工ID',
			field : 'userId',
			width : 50,
			hidden : true
		}, {
			title : '姓 名',
			field : 'userRealName',
			width : 50
		}, {
			title : '岗 位',
			field : 'posName',
			width : 85
		}, {
			title : '部门',
			field : 'groupName',
			width : 100
		}, {
			title : '分数',
			field : 'scoreMap',
			width : 660,
			formatter : function(value, row, index) {
				if(value) {
					var score = 0;
					score += value.column1Score;
					score += value.column2Score;
					score += value.column3Score;
					score += value.column4Score;
					
					if(score == 0) {
						return '';
					}
					
					var scoreInfo = '总分：' + score.toFixed(2)+'&nbsp;&nbsp;&nbsp;'
						+ value.column1Name +'：' + value.column1Score.toFixed(2)+'&nbsp;&nbsp;&nbsp;'
						+ value.column2Name +'：' + value.column2Score.toFixed(2)+'&nbsp;&nbsp;&nbsp;'
						+ value.column3Name +'：' + value.column3Score.toFixed(2)+'&nbsp;&nbsp;&nbsp;'
						+ value.column4Name +'：' + value.column4Score.toFixed(2)+'&nbsp;&nbsp;&nbsp;' ;
					//console.info(value);
					//$(value).each(function(i) {
						////console.info(this);
					//});
					return scoreInfo;
				}
				return '';
				//value *= 1;
				//return value.toFixed(2);
			}
		}, {
			title : '操作',
			field : 'action',
			width : 50,
			formatter : function(value, row, index) {
				return formatString('<img onclick="moduls_deterPerson_sugInfo(\'{0}\');" src="{1}"/>', row.userId, 'jslib/jquery-easyui-1.3.1/themes/icons/zoom.png');
			}
		} ] ]
	});
	
	initGroupListMenu();
});

function moduls_deterPerson_sugInfo(userId) {
	$('#deterPerson_sugDiv').dialog({ 
		width : 700,
		height : 500,
		closable : false,
		modal : true,
		title : '查看建议',
	    modal:true,
	    buttons : [ {
			text : '退出',
			iconCls : 'icon-remove',
			handler : function() {
				try {
					$('#deterPerson_sugDiv').dialog('close');
				}catch (e) {}
			}
		} ]
	});  
	$.ajax({
		type : 'POST',
		url : '${pageContext.request.contextPath}/deterPersonAction!getPersSug.action',
		data : {
			userId : userId
		},
		cache : false,
		dataType : 'JSON',
		success : function(r) {
			if(r) {
				var tempStr = '';
				for ( var i = 0; i < r.length; i++) {
					tempStr += (i + 1) + "、" + r[i].psCont + "<br /><br />";
				}
				$("#deterPerson_sugInfo").html(tempStr);
			}
		}
	});
}

function initGroupListMenu() {
	$.ajax({
		type : 'POST',
		url : 'deterPersonAction!getGroupList.action',
		cache : false,
		dataType : 'JSON',
		success : function(data) {
			for(var i = 0; i < data.length; i++) {
				$('div[id=groupListMenu]').menu('appendItem', {
		    		id: data[i].groupId,
		    		text: data[i].groupName,
		    		iconCls: 'icon-group'
		    	});
			}
		}
	});
	
	$("div[id=groupListMenu]").menu({   
	    onClick:function(item){   
	    	$('#moduls_deterPerson_deterStat_dialog_datagrid').datagrid('load', {
	        	groupId : item.id == undefined ? 0 : item.id
	        });   
	    }   
	}); 
}
</script>
